package com.cedar.controller; 

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.cedar.model.Client;
import com.cedar.service.ClientService;

/**  
 * @Author Bruce 
 * @Date 2012-11-25
 * @Comments
 */
@Controller
@RequestMapping("/client")
public class ClientController {
	private static final Logger logger = LoggerFactory.getLogger(ClientController.class); 
	
	@Autowired
	private ClientService clientService;
	
	@RequestMapping("/addClient")
	public String addCilent(){
		System.out.println(">>>>>>>>>>>>>>>");
		logger.info("添加客户信息...");
		return "client/addClient";
	} 
	
	@RequestMapping(value="/addClientSubmit",method=RequestMethod.POST)
	//public String addCilentSubmit(@ModelAttribute Client client){
	public String addCilentSubmit(@ModelAttribute("client") Client client){
		clientService.addClient(client);
		return "operate_success";
	}
	
	@RequestMapping(value="/addClientSubmit1",method=RequestMethod.POST)//
	public ModelAndView addCilentSubmit1(Client client){
		clientService.addClient(client);
		return new ModelAndView("operate_success", "msg", "添加客户信息操作。");
	}
}
 